import re
#这个文件名不能叫“re”，会重载原来的re包

#普通字符作为原子
pattern1 = 'yue'
pattern2 = 'yun'
string = 'http://yum.aqianyue.com'
result =  re.search(pattern1,string)
print(result)
result =  re.search(pattern2,string)
print(result)

#非打印字符作为原子
#\n-换行符、\t-制表符
string = '''http://yum.aqianyue.com
baidu'''
pattern3='\n'
result =  re.search(pattern3,string)
print(result)

string = '''http://yum.aqianyue.combaidu'''
pattern3='\n'
result =  re.search(pattern3,string)
print(result)

#通用字符作为原子（用得非常多）
'''
\w 匹配任意一个字母、数字、下划线
\W
\d 匹配任意一个十进制数
\D
\s 匹配任意一个空白字符
\S 匹配除空白字符意外得任意一个其他字符
'''
string = 'http://y um.aqi844788464anyue.com'
pattern1='\d\d'
result =  re.search(pattern1,string)
print(result)

pattern1='\d\d\d'
result =  re.search(pattern1,string)
print(result)

pattern1='\w\d\d'
result =  re.search(pattern1,string)
print(result)


pattern2='\w\s\d\d'
result =  re.search(pattern2,string)
print(result)
pattern2='\w\s\w\w'
result =  re.search(pattern2,string)
print(result)

#原子表
'''
可以定义一组地位平等的原子
'''
string = 'http://y um.aqi844788464anyue.com'
pattern1='aq[zbci]'
result =  re.search(pattern1,string)
print(result)

#^——非
pattern1='aq[^zbci]'
result =  re.search(pattern1,string)
print(result)



#原子表[^.]能够匹配换行符
string = 'dadjadb\r\ndaidka'
pattern1 = 'b[^.]*?d'
print(re.search(pattern1,string))
